﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTunesLibrary.Dal.Interop;
using iTunesLibrary.Dal.Xml;
using System.Threading.Tasks;
using iTunesLibrary.Music;

namespace iTunesLibrary
{
    public class iTunesService
    {
        private Library _library;

	public Library Library
	{
		get { return _library;}
		set { _library = value;}
	}
	

        private ILibraryProvider _provider;
        private string _inputPath;
        private LibraryParser _parser;
        private  itunesServiceState _state;
        private Task _serviceTask;
        private bool _taskIsBusy;
       
        public iTunesService ()
	    {
             _provider = new LibraryProvider();
	    }
          

        public void LoadLibrary()
        {
                _inputPath = _provider.Init();
                _state = itunesServiceState.ItunesStarted;
                _parser = new LibraryParser(_inputPath);
                _library = _parser.Load();
                _state = itunesServiceState.LibraryLoaded;
        }

        public void LoadObjects()
        {
            _provider.Load();
            _state = itunesServiceState.TracksLoaded;
        }

        enum itunesServiceState
        {
            Created = 0,
            ItunesStarted = 1,
            LibraryLoaded = 2,
            TracksLoaded = 3,

        }
    }
}
